import { createApp } from 'vue'
import App from './App.vue'
import http from './utils/http'
import auth from './utils/auth'
import dayjs from 'dayjs'


import router from "./routes"
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

const app =createApp(App)

// 全局引用封装的http/auth方法
app.use(http)
app.use(auth)
// app.use(message)
// app.use(messagebox)
app.use(router)
app.config.globalProperties.$http = http
app.config.globalProperties.$auth = auth
// app.config.globalProperties.$message = message
// app.config.globalProperties.$messagebox = messagebox

// 全局注册elementicon
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
  }  

  // 全局注册dayjs 格式化时间
  app.config.globalProperties.$filters = {
    format(value) {
        if (value) {
            return dayjs(value).format('YYYY-MM-DD HH:mm:ss')
        } else {
            return ''
        }
    }
}
app.mount('#app')
